//
//  DiUtil.h
//  DooiooOnline
//
//  Created by koki on 14-11-6.
//  Copyright (c) 2014年 dooioo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import<CoreText/CoreText.h>

@interface HDUtil : NSObject

//检查电话号码是否合法
+(BOOL)checkPhoneNumInput:(NSString *)number;
+(BOOL)checkMoblieNumber:(NSString *)number;

//检查邮箱是否合法
+(BOOL)checkEmail:(NSString *)email;
//身份证号
+ (BOOL)validateIdentityCard: (NSString *)identityCard;
//检查名字是否合法
+(BOOL)checkNameInput:(NSString *)number;

//检查密码是否合法
+(BOOL)checkPasswordInput:(NSString *)password;
//pragma mark 判断密码的正则表达式
+(BOOL)validatePassword:(NSString *)passWord;

//创建指定字窜的Label
+(UILabel*)UILabelWithText:(NSString*)text fontSize:(int)fontSize;
+(UILabel*)UILabelWithText:(NSString*)text boldFontSize:(int)fontSize;
+(UIButton*)buttonWithTitle:(NSString*)title frame:(CGRect)rect;
//获取字符窜大小
+(CGSize)getSizeWithText:(NSString*)text fontSize:(int)fontSize;
+(CGSize)getSizeWithText:(NSString*)text font:(UIFont*)font;
+(CGSize)getSizeWithText:(NSString*)text boldfontSize:(int)fontSize;
+(CGSize)sizeWithString:(NSString*) string  font:(UIFont*)font size:(CGSize)size;
+(CGSize)sizeWithString:(NSString*) string  attribute:(NSDictionary*)attribute size:(CGSize)size;
+(float)heightForTextViewSize:(CGSize)size  WithText: (NSString *) strText font:(UIFont*)font;
+(float)heightForTextViewSize:(CGSize)size  WithText: (NSString *) strText attribute:(NSDictionary*)attribute;
+(float)heightForTextViewSize:(CGSize)size  withAttributeText: (NSAttributedString *) attributeStrText;
//获取NSAttributed字符窜大小
+(CGSize)sizeWithString:(NSAttributedString*)attrStr size:(CGSize)size;

//按宽度获取图片合适尺寸
+ (CGSize)newSizeByOriginalSize:(CGSize)oldSize maxSize:(CGSize)mSize newWidth:(float)newWidth;

//MD5加密
+(NSString *)MD5:(NSString *)str;
//计算距今天数
+(int)calculateDaysFromDate:(NSDate*)date;
//计算两个日期之间的天数
+(int)calculateDaysFromDate:(NSDate*)fromDate toDate:(NSDate *)toDate;
//字符串转化成时间
+(NSDate*)getDateFromeString:(NSString*)str;
//将时间转化成字符串
+(NSString*)formatter:(NSString*) formattter FromeDate:(NSDate*)date;

//将时间字符串转化成特定格式的字符串
+(NSString*)formatter:(NSString*) formattter FromeDateStr:(NSString*)str;

//将时间字符串转化成时间戳
+ (NSInteger)getTimeSpwithTimestr:(NSString*)timeStr;

//时间戳转为时间字符串
+ (NSString*)getTimeStrFormatter:(NSString*)formattter withTimeSp:(NSInteger)currentInteger;
//是否是今年
+ (BOOL)isCurrentYear:(NSString *)timeStr;
+ (BOOL)isToday:(NSString *)timeStr;

//字符串转化
+(NSString*)check:(NSObject*)data;
+(NSString*)check:(NSObject*)data withDefaultStr:(NSString *)defaultStr;

+(NSArray*)checkArray:(NSArray*)array;
//校验空数组
+(NSArray*)checkNilArray:(NSArray*)array;
//浮点数处理并去掉多余的0
+(NSString *)stringDisposeWithDouble:(double)doubleValue;
//只保留位数，不进行四舍五入
+(NSString *)notRounding:(NSString*)price afterPoint:(int)position;
//校检NSNumber
+(NSNumber*)checkNumber:(NSNumber*)num;
//校检NSData
+(NSData*)checkData:(NSData*)value;
//添加分位符
+(NSString*)numberFormatterDecimalStyle:(NSNumber*)data;
//四舍五入
+(NSString*)strNumberRound:(NSObject*)data;
//检验价格
+ (NSString *)checkPrice:(NSObject*)data;

//电话
+(BOOL)call:(NSString *)phoneNumber;
//发短信
+(void)sendPhone:(NSString *)phoneNumber message:(NSString *)message vctr:(UIViewController*)Vctr;

+(NSString*)clearSpaces:(NSString*)str;
//获取当前版本
+(NSString *)currentVersion;
//隐藏键盘
+(void)hidenKeyBoard;
//提示弹出
+(void)showTipAlertWithMsg:(NSString*)msg;

//根据颜色生成纯色图片
+ (UIImage *)createImageWithColor:(UIColor *)color;

//截屏
+ (UIImage *)screenShot:(UIView *)view;

//浮窗提示
+(void)showMessage:(NSString *)message;

//mask image
+(UIImage*)maskImage:(UIImage*)image withMask:(UIImage*)maskImage;

//弹出登陆界面
+(void)presentLoginViewControllerSuccess:(void (^)())success;
//根据表名清空数据库表
+(void)deleteCoreDataWithEntity:(NSString*)entityName;
//判断设备型号
+ (NSString *)getCurrentDeviceModel;

//banner页跳转
+ (void)jumpFromBannerLink:(NSString *)link;

//获取view的view controller
+ (UIViewController *)getViewControllerFromView:(UIView *)view;

//数组/字典转json
+ (NSString *)getJson:(id)theData;
//json字符串转字典
+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;

//编码  URLEncodedString
+ (NSString *)URLEncodedString:(NSString *)string;
//解码  URLDecodedString
+ (NSString *)URLDecodedString:(NSString *)string;
//判断url是否加码 NO未加码 YES已加码
+ (BOOL)isUrlEncode:(NSString *)string;
//清理浏览器缓存
+(void)cleanWebViewCache;
@end














